﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BankCreditPortfolio.DAL.Services;

namespace BankCreditPortfolio.Core.Helpers
{
    public static class AccountHelper
    {
        public static string GetUsername(string email)
        {
            var user = new AccountService().GetByEmail(email);
            if (user.Role.Title == "Client")
            {
                var clientService = new ClientService();
                var client = clientService.GetProfileByEmail(email);

                return client.FirstName + " " + client.LastName;
            }
            if (user.Role.Title == "Admin")
                return email;

            var bankerService = new BankerService();
            var banker = bankerService.GetByEmail(email);

            return banker.Profile.FirstName + " " + banker.Profile.LastName;
        }

        public static bool IsClient(string email)
        {
            var accountService = new AccountService();
            if (accountService.GetRoleByEmail(email) != null)
            {
                if (accountService.GetRoleByEmail(email).Title == "Client")
                {
                    return true;
                }
            }
            return false;
        }

        public static bool IsBanker(string email)
        {
            return true;
        }
    }
}
